library(dplyr)
library(tidyr)
library(readr)
library(stringr)
library(ggplot2)
library(ggrepel)
library(topr)
library(UpSetR)
library(plyranges)
library(ieugwasr)
library(gwascat)
# Source helper functions
source("multi_funcs.R")

Principal components

plot_ancestry_PCs("antidep-2501-mrmega-N06A-DIV.log")

plot_ancestry_PCs("antidep-2501-mrmega-N06AA-DIV.log")

plot_ancestry_PCs("antidep-2501-mrmega-N06AB-DIV.log")

Manhattan plots

mrmega_n06a <- get_sumstats("antidep-2501-mrmega-N06A-DIV.gz")
## Rows: 10650849 Columns: 29
## ── Column specification ────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Delimiter: "\t"
## chr  (5): MarkerName, EA, NEA, Effects, CHR
## dbl (23): Chromosome, Position, EAF, Nsample, Ncohort, beta_0, se_0, beta_1,...
## lgl  (1): Comments
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
mrmega_n06aa <- get_sumstats("antidep-2501-mrmega-N06AA-DIV.gz")
## Rows: 9007284 Columns: 29
## ── Column specification ────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Delimiter: "\t"
## chr  (5): MarkerName, EA, NEA, Effects, CHR
## dbl (23): Chromosome, Position, EAF, Nsample, Ncohort, beta_0, se_0, beta_1,...
## lgl  (1): Comments
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
mrmega_n06ab <- get_sumstats("antidep-2501-mrmega-N06AB-DIV.gz")
## Rows: 10033491 Columns: 29
## ── Column specification ────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Delimiter: "\t"
## chr  (5): MarkerName, EA, NEA, Effects, CHR
## dbl (23): Chromosome, Position, EAF, Nsample, Ncohort, beta_0, se_0, beta_1,...
## lgl  (1): Comments
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
mrmega_n06a_assoc <- get_assoc(mrmega_n06a, "N06A")
mrmega_n06aa_assoc <- get_assoc(mrmega_n06aa, "N06AA")
mrmega_n06ab_assoc <- get_assoc(mrmega_n06ab, "N06AB")
plot_manhat(mrmega_n06a_assoc)

plot_manhat(mrmega_n06aa_assoc)

plot_manhat(mrmega_n06ab_assoc)

Clumps

clumps_N06A <- get_clumps("antidep-2501-mrmega-N06A-DIV.clumps.tsv")
clumps_N06AA <- get_clumps("antidep-2501-mrmega-N06AA-DIV.clumps.tsv")
clumps_N06AB <- get_clumps("antidep-2501-mrmega-N06AB-DIV.clumps.tsv")

clumps_N06A
clumps_N06AA
clumps_N06AB
clumps <- bind_rows(list("N06A-DIV" = clumps_N06A,
                         "N06AA-DIV" = clumps_N06AA,
                         "N06AB-DIV" = clumps_N06AB),
                    .id = "dataset")

write_csv(clumps, here::here("manuscript", "tables", str_c("clumps_mrmega_", "antidep-2501", ".clumps.csv")))

Catalogue

gwcat <- get_cached_gwascat()

gwascat_N06A_table <- look_up_snps(clumps_N06A, gwcat)
gwascat_N06AA_table <- look_up_snps(clumps_N06AA, gwcat)
gwascat_N06AB_table <- look_up_snps(clumps_N06AB, gwcat)

write.csv(gwascat_N06A_table, "multi_files/gwas_cat_N06A_table.csv", quote = F, row.names = F)
write.csv(gwascat_N06AA_table, "multi_files/gwas_cat_N06AA_table.csv", quote = F, row.names = F)
write.csv(gwascat_N06AB_table, "multi_files/gwas_cat_N06AB_table.csv", quote = F, row.names = F)